from queue import Queue


def hot_potato(name_list, num):
    result_queue = Queue()

    for name in name_list:
        result_queue.enqueue(name)

    while result_queue.size() > 1:
        for i in range(num):
            result_queue.enqueue(result_queue.dequeue())

        result_queue.dequeue()

    return result_queue.dequeue()


if __name__ == "__main__":
    name_list = ['a', 'b', 'c', 'd', 'e', 'f']

    print(hot_potato(name_list, 3))